﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;

namespace user.admin.cyt369.com.services.ORM
{
    public partial class UserContext: Microsoft.EntityFrameworkCore.DbContext
    {
        public UserContext()
        {
        }

        public UserContext(DbContextOptions<UserContext> options) : base(options)
        {

        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {

            if (Admin.CYT369.Com.Utility.SystemSettingService.Instance.user_admin_cyt369_com_connection_string.DBType == "SQLSERVER2008")
            {
                optionsBuilder.UseSqlServer(Admin.CYT369.Com.Utility.SystemSettingService.Instance.user_admin_cyt369_com_connection_string.ConnectionString).ReplaceService<Microsoft.EntityFrameworkCore.Query.IQueryTranslationPostprocessorFactory, Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServer2008QueryTranslationPostprocessorFactory>();
            }
            else
            {
                optionsBuilder.UseSqlServer(Admin.CYT369.Com.Utility.SystemSettingService.Instance.user_admin_cyt369_com_connection_string.ConnectionString);
            }
            base.OnConfiguring(optionsBuilder);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.App>().ToTable("TB_App");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.UserType>().ToTable("TB_UserType");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.User>().ToTable("TB_User");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.UserConfig>().ToTable("TB_UserConfig");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.UserLoginLog>().ToTable("TB_UserLoginLog");


            modelBuilder.Entity<user.admin.cyt369.com.services.Models.Terms>().ToTable("TB_Terms");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.TermsType>().ToTable("TB_TermsType");
            modelBuilder.Entity<user.admin.cyt369.com.services.Models.TermsFile>().ToTable("TB_TermsFile");

        }


    }
}
